#include "car_movectrl.h"

CarData_Struct my_car;

void Car_Stop()
{
	uint8_t txdata[8];
	for(int i=0;i<8;i++)
		txdata[i] = 0;
	Can_SendMessage(&hcan1,CANCMD_SetMotorSpeed,txdata,8);
}

void Car_Init()
{
	Uart_InitUartDMA(&huart5);
	CAN_FilterInit(&hcan1);
	Car_Stop();
}

void Car_Movectrl()
{
	SpeedCmd_struct *speed = &car_speed;
	uint8_t txdata[8];
	
	txdata[0] = (uint16_t)(speed->SpeedX*10000);
	txdata[1] = ((uint16_t)(speed->SpeedX*10000))>>8;
	txdata[2] = (uint16_t)(speed->SpeedY*10000);
	txdata[3] = ((uint16_t)(speed->SpeedY*10000))>>8;
	txdata[4] = (uint16_t)(speed->SpeedRotate*10000);
	txdata[5] = ((uint16_t)(speed->SpeedRotate*10000))>>8;
	txdata[6] = (uint16_t)speed->acc;
	txdata[7] = ((uint16_t)speed->acc)>>8;
	
	Can_SendMessage(&hcan1,CANCMD_SetPlatformSpeed,txdata,8);
}
